<?php

	namespace app\common\model;

	class SystemConfig extends Base{
		/**
		 * 获取单个参数配置
		 * */
		public static function getValue($menu){
			if (empty($menu) || !($config_one = self::get(['menu_name' => $menu]))) return false;
			return json_decode($config_one['value'], true);
		}

		/**
		 * 获得多个参数
		 * @param $menus
		 * @return array
		 */
		public static function getMore($menus){
			$menus = is_array($menus)?implode(',', $menus):$menus;
			$list = self::where('menu_name', 'IN', $menus)->column('value', 'menu_name')?:[];
			foreach ($list as $menu => $value){
				$value = json_decode($value, true);
				$list[$menu] = is_array($value) && $value[0]?$value[0]:$value;
			}
			return $list;
		}

		public static function getAllConfig(){
			$list = self::column('value', 'menu_name')?:[];
			foreach ($list as $menu => $value){
				$list[$menu] = json_decode($value, true);
			}
			return $list;
		}
	}